#include "svgwidget.h"

SvgWidget::SvgWidget(QWidget *parent)
    :QSvgWidget(parent)
{
//    render = new QSvgRenderer(this);
    render = renderer();
}

void SvgWidget::wheelEvent(QWheelEvent *e)
{
    const double diff =0.1;
    QSize size = render->defaultSize();
    int w = size.width();
    int h = size.height();
    if(e->delta()>0)
    {
        w = (int)(this->width()+this->width()*diff);
        h = (int)(this->height()+this->height()*diff);
    }
    else
    {
        w = (int)(this->width()-this->width()*diff);
        h = (int)(this->height()-this->height()*diff);
    }
    resize(w,h);
}

void SvgWidget::loadsvg(const string &svgfile)
{
    this->load(QString(svgfile.c_str()));
    auto r = this->renderer();
    this->resize(r->defaultSize());
//    render->load(QString(svgfile.c_str()));
}
